package com.zcp.month2.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zcp.month2.R;
import com.zcp.month2.bean.Bean;

import java.util.List;

/**
 * Created by Administrator on 2017/3/1.
 */

public class RightAdapter extends RecyclerView.Adapter<RightAdapter.MViewHolder> {

    List<Bean.RsBean.ChildrenBeanX> arr;
    LayoutInflater inflater;
    GridLayoutManager manager;
    Context context;
    public RightAdapter(Context context, List<Bean.RsBean.ChildrenBeanX> arr) {
        this.inflater=LayoutInflater.from(context);
        this.arr=arr;
        this.context=context;
    }

    @Override
    public MViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.right_item, parent, false);
        MViewHolder mm=new MViewHolder(view);
        return mm;
    }

    @Override
    public void onBindViewHolder(MViewHolder holder, int position) {
        holder.tv_right_name.setText(arr.get(position).dirName);
        List<Bean.RsBean.ChildrenBeanX.ChildrenBean> children = arr.get(position).children;
        holder.gv_recycle.setAdapter(new GridAdapter(context,children));

    }

    @Override
    public int getItemCount() {
        return arr.size();
    }

    class MViewHolder extends RecyclerView.ViewHolder
    {

        private final TextView tv_right_name;
        private final RecyclerView gv_recycle;

        public MViewHolder(View itemView) {
            super(itemView);
            tv_right_name = (TextView) itemView.findViewById(R.id.tv_right_name);
            gv_recycle = (RecyclerView) itemView.findViewById(R.id.gv_recycle);
            GridLayoutManager manager=new GridLayoutManager(context,3);
            gv_recycle.setLayoutManager(manager);
            //gv_recycle.addItemDecoration();
        }
    }
}
